package com.battle.service.controller.web;

import com.battle.pojo.param.label.*;
import com.battle.pojo.vo.label.*;
import com.battle.service.service.in.*;
import nirvana.core.domains.vo.PageResult;
import nirvana.core.domains.vo.ApiResult;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;

/**
 * web/标签
 * 【描 述】：
 * 【环 境】：J2SE
 * 【详 细】：
 */
@RestController
@RequestMapping("/label/web")
public class LabelWebController {

    private final LabelService service;

    public LabelWebController(LabelService service) {
        this.service = service;
    }


    /**
     * 创建标签
     *
     * @param param
     * @return
     */
    @PostMapping("/createLabel")
    public ApiResult createLabel(@RequestBody @Valid CreateLabelParam param) {
        service.createLabel(param);
        return ApiResult.ok();
    }


    /**
     * 修改标签
     *
     * @param param
     */
    @PutMapping("/editLabel")
    public ApiResult editLabel(@RequestBody @Valid EditLabelParam param) {
        service.editLabel(param);
        return ApiResult.ok();
    }

    /**
     * 移除标签
     *
     * @param id
     */
    @DeleteMapping("/removeLabel")
    public ApiResult removeLabel(@RequestParam("id") Long id) {
        service.removeLabel(id);
        return ApiResult.ok();
    }

    /**
     * 启动/禁用标签
     *
     * @param id
     */
    @GetMapping("/enabledLabel")
    public ApiResult enabledLabel(@RequestParam("id") Long id) {
        service.enabledLabel(id);
        return ApiResult.ok();
    }

    /**
     * 获取标签详情
     *
     * @param id
     * @return
     */
    @GetMapping("/getLabel")
    public ApiResult<GetLabelVo> getLabel(@RequestParam("id") Long id) {
        GetLabelVo vo = service.getLabel(id);
        return ApiResult.ok(vo);
    }

    /**
     * 获取标签列表
     *
     * @param param
     * @return
     */
    @PostMapping("/getLabelList")
    public ApiResult<PageResult<GetLabelListVo>> getLabelList(@RequestBody GetLabelListParam param) {
        PageResult<GetLabelListVo> result = service.getLabelList(param);
        return ApiResult.ok(result);
    }


    /**
     * 获取标签下拉列表
     *
     * @return
     */
    @PostMapping("/getLabelDownList")
    public ApiResult<List<GetLabelDownListVo>> getLabelDownList(@RequestBody(required = false) @Valid GetLabelDownListParam param) {
        List<GetLabelDownListVo> list = service.getLabelDownList(param);
        return ApiResult.ok(list);
    }

    /**
     * 清洗这个label是否系统
     *
     * @param
     * @return
     */
    @GetMapping("/updateLabel")
    public void updateLabel() {
        service.updateLabel();
    }
}

